<!DOCTYPE HTML>
<html>
    <head>
        <title> Test save boolean list </title>
        <meta content="text/html; charset=utf-8" http-equiv="content-type">
        <meta content="index, follow" name="robots">
        <meta content="content_keyword" name="keywords">
        <meta content="content_description" name="description">
        <meta content="web" name="generator">
    </head>
 
    <body>
      <script type='text/javascript'>

      //@link http://coding.smashingmagazine.com/2011/10/19/optimizing-long-lists-of-yesno-values-with-javascript/
      /**
      * Biến chuổi 100 vv... Thành 1 ký tự và truyền đi
      */
      function pack(/* string */ values) {
    	    var chunks = values.match(/.{1,16}/g), packed = '';
    	    for (var i=0; i < chunks.length; i++) {
    	        packed += String.fromCharCode(parseInt(chunks[i], 2));
    	    }
    	    return packed;
    	}

      //Biến kí tự thành bình thường
      /*
      
      Numbers in JavaScript have limits. For the methods discussed here that
      involve an intermediate state of converting to a number, the limit
      appears to be 1023 yes/no values, because parseInt('1111…1111', 2)
      returns Infinity when the number of aces is bigger than 1023.
      This limit does not apply to the last method, because we’re
      only converting blocks of bits instead of the whole thing.
      And, of course, it doesn’t apply to the first two methods
      (array and string) because they don’t involve packing the
      values into an integer.
      */
    	function unpack(/* string */ packed) {
    	    var values = '';
    	    for (var i=0; i < packed.length; i++) {
    	        values += packed.charCodeAt(i).toString(2);
    	    }
    	    return values;
    	}
      var a = pack('100');
      alert(a);
      var b = unpack(a);
      alert(b);
      var a = parseInt('96', 16).toString(2);
      alert(a);
      </script>
    </body>
</html>